function creatTables(){
	var connection=new SQLite("db.sqlite"); 
	try{
	connection.execute("CREATE TABLE IF NOT EXISTS tb_category (categoryId INTEGER PRIMARY KEY AUTOINCREMENT, categoryName STRING )");
	connection.execute("CREATE TABLE IF NOT EXISTS tb_reminder (reminderId INTEGER PRIMARY KEY AUTOINCREMENT, remind INTEGER)");	
	connection.execute("CREATE TABLE IF NOT EXISTS tb_repeat (repeatId INTEGER PRIMARY KEY AUTOINCREMENT, repeat INTEGER )"); 						
	connection.execute("CREATE TABLE IF NOT EXISTS tb_event (eventId INTEGER PRIMARY KEY AUTOINCREMENT,"+
						"categoryId INTEGER REFERENCES tb_category (categoryId), reminderId INTEGER REFERENCES tb_reminder (remindId),"+
						"repeatId INTEGER REFERENCES tb_repeat (repeatId),"+
						"datetime INTEGER, name STRING, description STRING,year INTEGER, month INTEGER, day INTEGER)");
	}catch(err){
		alert("I can't create the tables for the events! \n Please uninstall and install again.");
		return;
	}	
}

function initTables(){
	var connection = new SQLite("db.sqlite");
	try{
		connection.execute("INSERT INTO tb_reminder (remind) VALUES (500)");
		connection.execute("INSERT INTO tb_reminder (remind) VALUES (700)");
		connection.execute("INSERT INTO tb_reminder (remind) VALUES (800)");
		connection.execute("INSERT INTO tb_repeat (repeat) VALUES (5000)");
		connection.execute("INSERT INTO tb_repeat (repeat) VALUES (7000)");
		connection.execute("INSERT INTO tb_repeat (repeat) VALUES (8000)");
		connection.execute("INSERT INTO tb_category (categoryName) VALUES ('Birthday')");
		connection.execute("INSERT INTO tb_category (categoryName) VALUES ('Name day')");
		connection.execute("INSERT INTO tb_category (categoryName) VALUES ('Anniversary')");
		connection.execute("INSERT INTO tb_category (categoryName) VALUES ('Other')");		
	}catch(err){
		alert("Something it's bad. I think that you don't have the tables.");
		return;
	}
}

function deleteTables(){
	var connection = new SQLite("db.sqlite");
	try{
		connection.execute("DROP TABLE IF EXISTS tb_reminder");
		connection.execute("DROP TABLE IF EXISTS tb_repeat");
		connection.execute("DROP TABLE IF EXISTS tb_category");
		connection.execute("DROP TABLE IF EXISTS tb_event");
	}catch(err){
		alert("Something it's bad. I think that you don't have the tables.");
		return;
	}
}